from selenium.webdriver.common.by import By

from web_L3.po.BaseDriver import BaseDriver
from web_L3.po.Contact_Page import ContactPage


class BuildMember(BaseDriver):
    def input_name(self, name):
        # 调用找到并写入指定数据的方法
        self.find_and_send_keys(By.ID, 'username',name)
        return self

    def input_mark(self, id):
        self.find_and_click(By.ID, 'memberAdd_acctid')
        self.find_and_send_keys(By.ID, 'memberAdd_acctid',id)
        return self

    def input_phone(self, num):
        self.find_and_click(By.ID, 'memberAdd_phone')
        self.find_and_send_keys(By.ID, 'memberAdd_phone',num)
        return self

    def click_save(self):
        self.find_and_click(By.XPATH, "//*[@class ='qui_btn ww_btn js_btn_save']")
        return ContactPage(self.driver)
    def click_save_fail(self):
        self.find_and_click(By.XPATH, "//*[@class ='qui_btn ww_btn js_btn_save']")
        ele = self.driver.find_element(By.CSS_SELECTOR,'.member_edit_item_right.ww_inputWithTips_WithErr>div:nth-child(2)')
        return ele.text